<%@page import="servlet.CommitteeTable"%>
<%@page import="Logic.Authorizer"%>
<%@page import="servlet.CommitteeFilterDropdown"%>
<%@page import="java.util.*,Model.Committee" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<!-- Declare the first header -->
<jsp:include page="t_header.jsp" />


<script type="text/javascript">
	$(document).ready(function() {
		$(".committeeapprovedlist").change(function() {

			var value = this.value;

			if (value == "all") {
				$(".approvedcommitteebody tr").show();
			}

			else {
				$(".approvedcommitteebody tr").show();
				$(".approvedcommitteebody tr").not("." + value).hide();
			}
		});
	});
	function deleteConfirm()
	{
		return confirm("Are you sure you want to delete this record?") ? true:event.preventDefault();
	}
</script>


<jsp:include page="header.html" />
<!-- Declare sidebar -->
<jsp:include page="t_siderbarcommittee.jsp" />

<!-- Main Content -->
<section id="main" class="column">
	<%
		if (request.getParameter("error") != null) {
			if (request.getParameter("error").equals("-1"))
				out.print("<h4 class='alert_success'>Committee deleted successfully.</h4>");
			else if (request.getParameter("error").equals("-2")) {
				out.print("<h4 class='alert_success'>Committee updated successfully.</h4>");
			}
		}
	%>
	<article class="module width_full">
		<header>

			<table style="border-spacing: 0;">
				<tr>

					<td style="width: 40%;">

						<h3 class="tdmar1">View committee</h3>

					</td>

					<td style="width: 20%; right: 255px; position: absolute;"><p
							class="tdmar2">View by Committee:</p></td>

					<td
						style="width: 40%; right: 5px; margin-top: 3px; position: absolute;"><select
						id="committeeapprovedlist" class="committeeapprovedlist tdmar3"
						style="width: 100%; float: left;">
							<%
								CommitteeFilterDropdown atd = new CommitteeFilterDropdown(out);
								atd.doGet(request, response);
							%>
					</select></td>


				</tr>
			</table>
		</header>


		<table class="tablesorter" cellspacing="0">
			<thead>
				<tr>
					<th style="width: 13%">Title</th>
					<th style="width: 23%">Purpose</th>
					<th style="width: 23%">Role</th>
					<th style="width: 13%">Staff</th>
					<th style="width: 13%">Effective Date</th>
					<th style="width: 3%">Edit/Delete</th>
					<th style="width: 3%">Print</th>
				</tr>
			</thead>
			<tbody class="approvedcommitteebody">
				<% 
					ArrayList<Committee> commArr = new ArrayList<Committee>();
					Committee com = new Committee();
					commArr = Committee.getApprovedCommittees();
					for(int i = 0; i < commArr.size(); i++)
					{
						com = commArr.get(i);
						ArrayList<String> staffNames = com.getStaffList();
						ArrayList<String> roleList = com.getRoles();
				 %>
				 <tr id="commTable2" class="<%=com.getId() %>">
				 	<td><%= com.getTitle() %></td>
				 	<td><%= com.getPurpose() %></td>
				 	<td><% for (String role : roleList){%>
					<%= role %><br/>
					<% } %>
					</td>
				 	<td>
				 	<% 
				 		for(String staffName : staffNames){
				 	%>
				 	<%= staffName %><br/>
				 	<% } %>
				 	</td>
				 	<td><%= com.getDate() %></td>
					<td><a href="\QMS\committee_modifycomm.jsp?action=e&id=<%=com.getId() %>"/>Edit</a>|<a id="delete" onclick="deleteConfirm()" href="CommitteeDelete?id=<%=com.getId()%>">Delete</a></td>
					<td><a href="CommitteePrint?id=<%=com.getId()%>" target="_blank">Print</a></td> 
				 </tr>
				 <%} %>
			</tbody>
		</table>
<script>

		/* 	$('#delete').click(function()
			{
				return confirm("Are you sure you want to delete this record?") ? true:event.preventDefault();
			});	 */
	</script>



	</article>
	<!-- end of content manager article -->
	<div class="spacer"></div>
</section>

<!-- Declare closing tags -->
<jsp:include page="t_footer.jsp" />